using HCore.Unity.Behaviour.Handler;
using Session;
using UnityEngine.EventSystems;

namespace UI.UIGame
{
    public class OverlayOnGameUI : SessionHCoreMonoBehaviour<IUIGameSession>
    {
        private void Start()
        {
            var pointHandler = GetOrAddComponent<PointHandler>();
            pointHandler.OnPointerEnterEvent += SetIsMouseOverlayOnGameUITrue;
            pointHandler.OnPointerExitEvent += SetIsMouseOverlayOnGameUIFalse;
        }

        private void SetIsMouseOverlayOnGameUITrue(PointerEventData eventData)
        {
            if (Session == null) return;
            Session.IsMouseOverlayOnGameUI = true;
        }

        private void SetIsMouseOverlayOnGameUIFalse(PointerEventData eventData)
        {
            if (Session == null) return;
            Session.IsMouseOverlayOnGameUI = false;
        }
    }
}